import Vue from 'vue'
import Vuex from 'vuex'



Vue.use(Vuex)

const state = {
  token: null,//token
  menus: [],//用户菜单
};
const getters = {
  token: state => state.token,//获得token
  menus: state => state.menus,//获得菜单
};

const mutations = {
  //存入用户token
  putToken(state, token) {
    state.token = token;
  },
  //存入用户菜单
  putUserMenus(state, menus) {
    state.menus = menus;
  }
};

const actions = {
  //存入用户token
  putToken({ commit }, token) {
    commit('putToken', token);
  },
  //存入用户菜单
  putUserMenus({ commit},token) {
    commit('putUserMenus',token);    
  }
};

const store = new Vuex.Store({
  state,
  getters,
  mutations,
  actions,
  modules: {}
});




export default store;
